export default class CatMap extends godot.TileMap {

    tileId = 1;
    

    constructor(){
        super();
        // 初始化TileSet
        this.initTileSet();

        this.cell_size = new godot.Vector2(32,32);
        console.log("dccc")

        for (let i = 0; i < 5; i++) {
            for (let j = 0; j < 5; j++) {
                // x,j代表tileMap的Cell坐标
                // tile代表贴图索引编号
                // autotile_coord 代表autotile的索引
                this.set_cell(i,j,1,false,false,false,new godot.Vector2(i,j));
            }
        }
    }

    initTileSet(){
        
        let tileSet = new godot.TileSet();

        tileSet.create_tile(this.tileId);
        tileSet.tile_set_texture(this.tileId,godot.load("res://Cat1-1.png") as godot.Texture);
        tileSet.tile_set_region(this.tileId,new godot.Rect2(0,0,512,512));
        
        // 块大小
        tileSet.autotile_set_size(this.tileId,new godot.Vector2(32,32));
        tileSet.tile_set_tile_mode(this.tileId,godot.TileSet.ATLAS_TILE);
    

        this.tile_set = tileSet;
    }
}